Repository navigation
Conversation
dbcc5c1 to
4d56fe7
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Critical bugs remain: restacking can replace a grown device’s live size with an older size, while queued writes can modify a sealed file before hitting a null-index assertion.
5 open issues
What changed in this PR
This PR reworks LSMT concurrency to allow parallel appends while coordinating writes with snapshots, resizing, and sealing.
Changes:
- Replace append serialization with shared/exclusive locking and atomic append-position allocation.
- Move resize handling into LSMT, enforce virtual-size write limits, and propagate filesystem-resize link dependencies.
- Add concurrency and resize tests, reject zero-size image creation, and update snapshot documentation.
| File | Description |
|---|---|
src/ublk/ublk_device.cpp |
Clarifies failed filesystem-grow behavior in a comment. |
src/tools/overlaybd-create.cpp |
Rejects zero virtual size. |
src/overlaybd/lsmt/test/test.cpp |
Adds parallel-write, restack, and filesystem-resize coverage. |
src/overlaybd/lsmt/file.h |
Replaces public update_vsize with resize. |
src/overlaybd/lsmt/file.cpp |
Implements concurrency control, parallel appends, and locked resizing. |
src/overlaybd/lsmt/CMakeLists.txt |
Propagates filesystem-resize dependencies to LSMT consumers. |
src/image_file.cpp |
Delegates resizing to LSMT. |
src/CMakeLists.txt |
Removes resize dependencies moved to LSMT. |
docs/live-snapshot.md |
Documents automatic snapshot/write coordination. |
docs/live-snapshot_zh.md |
Updates the Chinese snapshot-locking documentation. |
Review effort: Balanced
4d56fe7 to
c9d6f33
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Storage locking, append allocation, and resize reentrancy require multi-vCPU runtime validation, which is blocked here by unavailable Photon/e2fsprogs dependencies and the absent extfs callback implementation.
No open issues 🎉
5 resolved since last review
Review effort: Balanced
|
Why does IOPS decrease monotonically as the number of threads increases? If that is the case, why use multithreading? |
@liulanzheng The benchmark uses psync IO engine with 1 vCPU and N photon threads. A psync syscall blocks the whole vCPU, so adding photon threads does not add IO concurrency, it only adds synchronization overhead. The monotonic decrease in IOPS reflects that overhead. Multi-vCPU results (psync, 4K writes, 8192 writes per vCPU, 3 runs, best):
The baseline serializes every append on m_rw_mtx, so adding vCPUs only increases contention and cross-vCPU wakeup cost, and IOPS decreases monotonically. After this change, appends run in parallel, so IOPS scales with vCPU count up to 4 vCPUs. |
c9d6f33 to
2606cc5
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The lock-bypassing resize view depends on unavailable Photon extfs behavior, leaving its I/O contract and concurrent resize, restack, write, and failure paths in need of dependency-aware runtime validation.
No open issues 🎉
Review effort: Balanced
…ight writes Signed-off-by: huangzhaoxiang.hzx <huangzhaoxiang.hzx@alibaba-inc.com>
2606cc5 to
6da0c72
Compare
| if (offset < 0 || (uint64_t)offset > m_vsize || count > m_vsize - (uint64_t)offset) | ||
| LOG_ERROR_RETURN(EINVAL, -1, "write beyond virtual size: offset:`, len:`, vsize:`", | ||
| offset, count, m_vsize); |
| int resize(uint64_t target_size, bool resize_fs = false) override { | ||
| if ((target_size % ALIGNMENT4K) != 0) | ||
| LOG_ERROR_RETURN(EINVAL, -1, "target size must be 4K aligned, got `", target_size); | ||
| photon::scoped_rwlock lsmt_lock(m_lsmt_rwlock, photon::WLOCK); |


What this PR does / why we need it:
restack,resize,close_sealandSet_Data_File_Direct_IOchange the LSMT structure,m_vsizeor the append cursor, but none of them was excluded from in-flight writes, and they were not mutually exclusive either. hybrid/sparse writes could land in a sealed layer, index records could disagree with the stack,m_vsizecould be read while being bumped, and the direct-IO cursor update could move backwards.m_rw_mtx, even for disjoint ranges, so throughput dropped as concurrency grew.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Rework concurrency control for LSMT writable layers. Appends no longer serialize, and operations that change the layer stack or its metadata (restack, resize, close_seal) are mutually exclusive with in-flight writes.
m_data_offset.fetch_add. With direct IO, lengths are rounded up to 4K and zero padded, so concurrent appends do not enter the aligned adaptor's read-modify-write path.IFileRW::resizeand move the current-size read, grow/shrink decision andupdate_vsizefrom ImageFile intoLSMTFile, all under the write lock. The filesystem resize runs through a lock-free view soresize_extfsdoes not re-enter the lock through this layer'spwrite.update_vsizefromIFileRW; it is now an internal LSMT method.m_vsizea hard limit for writes: out-of-range writes returnEINVAL. Writers no longer bumpm_vsize, so it is only written by resize and restack under the write lock.close_sealandSet_Data_File_Direct_IO.Performance
Test Configuration: Append layer, psync I/O engine, 8192 writes per writer, 3 runs, best.
Single vCPU, N photon threads:
Multi-vCPU, 1 photon thread per vCPU:
The baseline serializes every append on
m_rw_mtx. Consequently, increasing the number of vCPUs only adds contention and cross-vCPU wakeup costs, causing IOPS to decrease monotonically. After this change, appends can run in parallel, allowing IOPS to scale with the vCPU count (up to 4 vCPUs).Please check the following list: